﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using Microsoft.SqlServer.Dts.Pipeline;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Pipeline.Design;
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Design;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;

namespace Pestre.SqlServer.SSIS.DataFlowComponent
{
    /*
     * ColumnInfo provides getter et setter to manipulates information on a column.
     * The following information can be stored in this class : 
     *    - Name of the column
     *    - Data Type of the column
     *    - Length of the column
     *    - LineageID of the column
     *    
     * This class is used in an array to store information for all columns in the
     * data flow. Afterward, during running time, this information will be restituted
     * and written to the Output buffer.
     */
    public class ColumnInfo90
    {
        private int iLineageID;   // LineageID is an unique identifier for column in a package
        private string sName;     // Name given to the column
        private string sDataType; // Data Type (Int, String, etc...)
        private int iLength;      // Lengh of the column (0, 50, etc...)

        /* 
         * Build a default instance with default values.
         */
        public ColumnInfo90()
        {
            // Set default values
            iLineageID = 0;
            sName = "";
            sDataType = "";
            iLength = 0;
        }

        /* 
         * Build an instance with all values spécified in parameters.
         */
        public ColumnInfo90(int LineageID, string Name, string DataType, int Length)
        {
            iLineageID = LineageID;
            sName = Name;
            sDataType = DataType;
            iLength = Length;
        }

        /*
         * Get and Set LineageID.
         */
        public int LineageID
        {
            get { return iLineageID; }
            set { iLineageID = value; }
        }

        /*
         * Get and Set Name
         */
        public string Name
        {
            get { return sName; }
            set { sName = value; }
        }

        /*
         * Get and Set DataType
         */
        public string DataType
        {
            get { return sDataType; }
            set { sDataType = value; }
        }

        /*
         * Get and Set Length
         */
        public int Length
        {
            get { return iLength; }
            set { iLength = value; }
        }

        /*
         * Transform this instance of ColumnInfo in a storable format.
         * The returned string will be stored in a custom property.
         *    - Each attribut is converted to String
         *    - Attributs are separated with ':'
         *    - At the end of the string a ';' is added
         */
        public override string ToString()
        {
            return iLineageID.ToString() + ':'
                    + sName.ToString() + ':'
                    + sDataType.ToString() + ':'
                    + iLength.ToString() + ';';
        }
    }
}